<?php


namespace App\Models\Chat;
use App\Models\CarModels\CarArea;
use App\Models\SystemManagement\Department;
use App\Models\SystemManagement\DepartmentEmployee;
use App\Models\SystemManagement\Employee;
use App\Models\SystemManagement\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Facade;
use DB;
class ChatGroup extends Model
{
    protected $table = 'chat_group';
    protected $fillable = ['name','employee_id'];

    function users(){
        return $this->belongsToMany(Employee::class,ChatEmployUsers::class,'chat_group_id','employee_id');
    }

    function departments()
    {
        return $this->belongsToMany(Department::class,ChatEmployDepartment::class,'chat_group_id','employ_department_id')->with('users');
    }
}